import torch
import torchvision
from torch.utils.data import DataLoader
from torch.utils.tensorboard import SummaryWriter

input = torch.tensor([[1,2,0,3,1],
                     [0,1,2,3,1],
                     [1,2,1,0,0],
                     [5,2,3,1,1],
                     [2,1,0,1,1]],dtype=torch.float32
                     )

class MyNN(torch.nn.Module):
    def __init__(self):
        super(MyNN, self).__init__()
        self.max_pool = torch.nn.MaxPool2d(kernel_size=3,ceil_mode=False)

    def forward(self,input):
        output=self.max_pool(input)
        return output

my_nn = MyNN()

print(input)
input = torch.reshape(input,(-1,1,5,5))
output = my_nn(input)
print(output)

dataset = torchvision.datasets.CIFAR10("./dataset_2",train=False,transform=torchvision.transforms.ToTensor(),download=True)
data_loader = DataLoader(dataset=dataset,batch_size=64)
writer = SummaryWriter("logs_maxpool")

step= 1
for data in data_loader:
    imgs,lables = data
    writer.add_images("input",imgs,step)
    output = my_nn(imgs)
    writer.add_images("output",output,step)
    step=step+1

writer.close()
